<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AAA在线翻译</title>
    <style>
        body {
            font-family: 'Arial', sans-serif;
            margin: 0;
            padding: 20px;
            background-color: #f5f5f5;
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
            background-color: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
        }

        .content-container {
            display: flex;
            gap: 30px; /* 增加间距 */
        }

        .left-panel {
            flex: 1;
        }

        .right-panel {
            flex: 1;
        }

        .form-group {
            margin-bottom: 20px;
        }

        label {
            display: block;
            margin-bottom: 8px;
            font-weight: bold;
        }

        textarea {
            width: 100%;
            min-height: 150px;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            resize: vertical;
        }

        select {
            width: 100%;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
        }

        .button-group {
            margin-top: 10px;
        }

        /* 添加按钮样式 */
        .btn {
            background-color: #007bff;
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 14px;
            transition: background-color 0.3s ease;
        }

        .btn:hover {
            background-color: #0056b3;
        }

        .btn:focus {
            outline: none;
            box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
        }
    </style>
</head>
<body>

<div class="container">
    <div class="header">
        <div class="title">AAA在线翻译</div>
        <button class="btn"  onclick="toManagePage()">查看翻译历史记录</button>
    </div>

    <div class="content-container">
        <div class="left-panel">
            <div class="form-group">
                <label for="sourceText">请输入原文：</label>
                <textarea id="sourceText" placeholder="请输入要翻译的文本"></textarea>
            </div>

            <div class="form-group">
                <label for="targetLang">请选择要翻译的语言</label>
                <select id="targetLang">
                    <option value="en">英语</option>
                    <option value="jp">日语</option>
                    <option value="fra">法语</option>
                </select>
            </div>

            <div class="button-group">
                <button class="btn" onclick="xxx()">开始翻译</button>
            </div>
        </div>

        <div class="right-panel">
            <div class="result-container">
                <label for="resultText">翻译结果：</label>
                <textarea id="resultText"></textarea>
            </div>
        </div>
    </div>
</div>


</body>
<script>
    function toManagePage(){
        window.location.href = 'trans_manage.html';
    }
    function xxx() {
        const sourceText = document.getElementById('sourceText').value;
        const targetLang = document.getElementById('targetLang').value;
        const resultText = document.getElementById('resultText');

        // 这里可以添加实际的翻译逻辑
        // 例如调用后端API进行翻译
        if (sourceText.trim() === '') {
            alert('请输入要翻译的文本！');
            return;
        }

        // 调用后端翻译接口
        fetch('/api/translate', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({
                sourceText: sourceText,
                targetLang: targetLang
            })
        })
            .then(response => response.json())
            .then(data => {
                if (data.success) {
                    resultText.value = data.translatedText;
                } else {
                    alert('翻译失败: ' + data.error);
                }
            })
            .catch(error => {
                alert('请求失败: ' + error);
            });
    }
</script>
</html>
